package cn.etynit.fallback;

import cn.etynit.domain.UserMovie;
import cn.etynit.exception.GlobalExceptionCodeEnum;
import cn.etynit.feign.UserMovieService;
import cn.etynit.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserMovieServiceFallbackFactory implements FallbackFactory<UserMovieService> {

    @Override
    public UserMovieService create(Throwable throwable) {
        return new UserMovieService() {
            @Override
            public JsonResult getUserStock(Long userId, Long movieId) {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }

            @Override
            public JsonResult saveOrUpdate(UserMovie userMovie) {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }
        };
    }
}
